<template>
  <div>
    <el-form :inline="true" :model="queryForm" @keyup.enter.native="getDataList('reset')">
      <el-form-item label="真实姓名">
        <el-input v-model="queryForm.real_name" maxlength="10" placeholder="真实姓名" clearable></el-input>
      </el-form-item>
      <el-form-item label="手机号">
        <el-input v-model="queryForm.mobile" type="number" maxlength="11" placeholder="手机号" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="getDataList('reset')">查询</el-button>
        <el-button icon="el-icon-refresh-left" @click="reset">重置</el-button>
      </el-form-item>
    </el-form>
    <el-radio-group v-model="queryForm.status" style="margin-bottom: 30px;" @change="statusChange">
      <el-radio-button :label="-1">全部</el-radio-button>
      <el-radio-button :label="0">待审核</el-radio-button>
      <el-radio-button :label="1">已通过</el-radio-button>
      <el-radio-button :label="2">已驳回</el-radio-button>
    </el-radio-group>

    <el-table :data="dataList" border v-loading="dataListLoading" style="width: 100%;">
      <el-table-column align="center" label="序号" width="180">
        <template slot-scope="scope">
          <span>{{(queryForm.page - 1) * queryForm.limit + scope.$index + 1}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="real_name" header-align="center" align="center" label="真实姓名">
      </el-table-column>
      <el-table-column prop="id_card" header-align="center" align="center" label="身份证号">
      </el-table-column>
      <el-table-column prop="mobile" header-align="center" align="center" label="联系电话">
      </el-table-column>
      <el-table-column prop="isccc_lable" header-align="center" align="center" label="认证标签">
        <template slot-scope="{row}">
          <span v-if="row.isccc_lable==0">智力残疾</span>
          <span v-if="row.isccc_lable==1">视力残疾</span>
          <span v-if="row.isccc_lable==2">听力残疾</span>
          <span v-if="row.isccc_lable==3">言语残疾</span>
          <span v-if="row.isccc_lable==4">肢体残疾</span>
          <span v-if="row.isccc_lable==5">精神残疾</span>
        </template>
      </el-table-column>
      <el-table-column prop="mobile" header-align="center" align="center" label="认证地区">
        <template slot-scope="{row}">
          {{row.province_name+' '}} / {{' '+row.city_name+' '}} / {{' '+row.area_name}}
        </template>
      </el-table-column>
      <el-table-column prop="status" header-align="center" align="center" label="状态">
        <template slot-scope="{row}">
          <el-tag v-if="row.status===0">待审核</el-tag>
          <el-tag v-if="row.status===1" type="success">已通过</el-tag>
          <el-tag v-if="row.status===2" type="danger">已驳回</el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="apply_time" header-align="center" align="center" label="提交时间">
      </el-table-column>
      <el-table-column fixed="right" header-align="center" align="center" width="150" label="操作">
        <template slot-scope="{row}">
          <el-button type="text" v-if="row.status!==0" size="small" @click="openDetails(0,row)">查看详情</el-button>
          <el-button type="text" v-else size="small" @click="openDetails(1,row)">审核</el-button>
          <!-- <el-button type="text" size="small">删除</el-button> -->
        </template>
      </el-table-column>
    </el-table>

    <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="queryForm.page" :page-sizes="[10, 20, 50, 100]" :page-size="queryForm.limit" :total="total" layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>

    <detail :id="activeIem.id" :type="detailType" :show.sync="detailShow" @change="getDataList()"></detail>
  </div>
</template>

<script>
import authenticationService from '@/api/authenticationService.js'
import detail from './details'
export default {
  components: {
    detail
  },
  data () {
    return {
      queryForm: {
        limit: 10,
        page: 1,
        status: -1
      },
      total: 0,
      dataList: [],
      dataListLoading: false,
      detailShow: false,
      activeIem: {},//选中
      detailType: 0,//详情类型  0详情  1审核
    }
  },
  created () {
    this.getDataList()
  },
  methods: {
    // 打开详情弹窗
    openDetails (type, item) {
      this.detailShow = true;
      this.activeIem = item;
      this.detailType = type;
    },
    // 获取列表
    getDataList (reset) {
      if (reset) this.queryForm.page = 1
      this.dataListLoading = true;
      authenticationService.getDisabilityauthPage(this.queryForm).then(res => {
        if (res && res.data.code == 200) {
          this.dataList = res.data.page.list;
          this.total = res.data.page.totalCount;
        }
        this.dataListLoading = false;
      })
    },
    // 每页数
    sizeChangeHandle (val) {
      this.queryForm.limit = val
      this.getDataList()
    },
    // 当前页
    currentChangeHandle (val) {
      this.queryForm.page = val
      this.getDataList()
    },
    // 重置
    reset () {
      this.queryForm = {
        limit: 10,
        page: 1,
        status: -1
      }
      this.getDataList()
    },
    statusChange () {
      this.queryForm.page = 1;
      this.getDataList()
    }
  }
}
</script>

<style>
.el-form--inline .el-form-item__content {
  width: auto !important;
}
input[type='number'] {
  -moz-appearance: textfield;
}
input[type='number']::-webkit-inner-spin-button,
input[type='number']::-webkit-outer-spin-button {
  -webkit-appearance: none;
}
</style>